package com.kkb.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/default")
public class DefaultController {
    @GetMapping("/gotoResultModel")
    public String defaultGetModel(Model model){
        model.addAttribute("name","富贵Model");
        System.out.println("defaultGetModel");
        return "result";
    }

    @GetMapping("/gotoResultModelMap")
    public String defaultGetModelMap(ModelMap modelMap, Integer id){
        modelMap.addAttribute("name","富贵ModelMap");
        modelMap.addAttribute("id",id);
        return "result";
    }

    @GetMapping("/gotoResultRedirect")
    public String defaultGetModelMapRedirect(ModelMap modelMap){
        modelMap.addAttribute("id","2");
        return "redirect:/default/gotoResultModelMap.do";
    }

    @GetMapping("/gotoResultForward")
    public String defaultGetModelMapForward(ModelMap modelMap){
        modelMap.addAttribute("id","3");
        modelMap.addAttribute("name","富贵Forward");
        return "forward:/default/gotoResultModelMap.do";
    }
}
